package android.slc.module.component.webview

import android.slc.appbase.ui.AppView
import android.slc.appbase.utils.AppIntentUtils
import android.slc.box.core.property.DataChangeListener
import android.slc.box.core.virtual_android.Bundle
import javafx.fxml.FXML
import javafx.scene.web.WebView

/**
 * @author slc
 * @date 2024/8/13
 **/
class WebkitView : AppView<WebkitVm>() {
    companion object {
        fun getIntentBundle(url: String): Bundle {
            return AppIntentUtils.getBundleByData(url)
        }
    }

    @FXML
    private lateinit var webView: WebView

    override fun onBindView() {
        super.onBindView()
        webView.engine.isJavaScriptEnabled = true
    }

    override fun onRegisterLiveEvent() {
        super.onRegisterLiveEvent()
        viewModel.urlLd.addListener(DataChangeListener { url ->
            webView.engine.load(url)
        })
    }

    override fun onBindViewLater() {
        super.onBindViewLater()
        viewModel.initVm()
    }
}